import React, { useEffect, useState } from 'react'
import "./index.css"
import "../../../icon/iconfont.css"
import { withRouter } from 'react-router-dom'
import { getUserInfo } from "../../../api/userinfo"

import QRCodeAlert from '../../../components/QRcode_Alert'
function Homey(props) {
  
  const [user, setUser] = useState("getUserInfo")
  console.log(user);
  useEffect(() => {
    getUserInfo({phone: '18234824645'}).then((res)=>{
      setUser(res)
    })
    setTimeout(() => {

    },1000 );


  }, [])

  console.log(user);
  return (
    <div><div className='box'>
      <div className='box2_gzq'>
        <img className='img1_gzq' src={require("../img/1.png")} />
        <div className='lucency'>

        </div>
        <div className='cubebox'>
          <div className='cube'>
            <div className='cube2'>
              <img alt="" className='img2_gzq' src='/img/home/加载.png'
                onClick={() => {
                  props.history.push('/userinfo')
                }} />
              <p className='baby'>鱼宝</p>
            </div>

            <div onClick={() => {
              props.history.push("/Shop")
            }}>
              <p className='p1'>{user[0].integral}</p>
              <p className='p2'>积分</p>
            </div>
            <div 
               onClick={() => {
                props.history.push("/Car")
              }}
            >
              <p className='p1'>{user[0].coupons}张</p>
              <p className='p2'>优惠劵</p>
            </div>
           
              <QRCodeAlert></QRCodeAlert>
            
          </div>
        </div>
      </div>
      <div className='orderBox'>
        <div className='order' >
          <div className='food' onClick={()=>{
            props.history.push("/Camera")
          }}>
            <img className='img3' src="/img/home/首页1.png" alt="" />
            <p className='orderp'>堂食点餐
             
            </p>
            <p className='orderp2'>活鱼现选现烤</p>
          </div>
          <div className='delivery' onClick={()=>{
            props.history.push("/Layout/Takeout")
          }}>
            <img className='img4' src="/img/home/首页2.png" alt="" />
            <p className='orderp1'>外卖/自取/点餐</p>
            <p className='orderp2'>宅家也能吃烤鱼</p>
          </div>
        </div>
      </div>
      <div className='inteBox'>
        <div className='inteBox2'>
          <div className='inteleft inte'>
            <div className='inte1'>
              <p className='intep1'
                onClick={() => {
                  props.history.push("/Payment")
                }}
              >付费劵包</p>
              <p className='intep2'>优惠享不停</p>
            </div>
            <img src="/img/home/首页3.png" alt="" />
          </div>
          <div className='interight inte' 
            onClick={()=>{
              props.history.push("/Shop")
            }}
          >
            <div className='inte1'>
              <p className='intep1'
              onClick={() => {
                props.history.push("/Car")
              }}>积分商城</p>
              <p className='intep2'>积分商城享好礼</p>
            </div>
            <img src="/img/home/首页4.png" alt="" />

          </div>

        </div>
      </div>
      <div className='liveFish'>
        <img src="/img/home/养鱼.png" alt="" />
      </div>
    </div></div>
  )
}



const mapStateToProps = (state) => ({
  UserList: state.user.user, 
  userListt: state.user 
} )

console.log();
const mapDispatchToProps = {}

export default withRouter(Homey)